using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Drawing2D;

namespace BPMN.MainWindow
{
    public abstract class Event : FlowObject
    {
        public EventType eventType;
        public EventType EventType
        {
            get
            {
                return eventType;
            }
            set
            {
                eventType = value;
            }
        }
        public Event()
        {
            Location = new PointF(0, 0);
            Size = new SizeF((float)100.0, (float)100);
            BoundingBox = new RectangleF(Location, Size);
            State = FigureState.Unselected;
        }
        public Event(PointF location, SizeF size, FigureState state)
        {

            this.Location = location;
            this.Size = size;
            PointF LocationBoundingBox = new PointF(location.X - size.Width / 2, location.Y - size.Height / 2);
            SizeF SizeBoundingBox = new SizeF(size.Height, size.Width);
            BoundingBox = new RectangleF(LocationBoundingBox, SizeBoundingBox);
            State = FigureState.Unselected;
            updateHotSpots();
            this.Path = new GraphicsPath();
            Path.AddEllipse(LocationBoundingBox.X, LocationBoundingBox.Y, SizeBoundingBox.Width, SizeBoundingBox.Height);
            Region = new Region(Path);
            State = FigureState.Unselected;
        }
        public Event(PointF location, SizeF size)
        {
            this.Location = location;
            this.Size = size;
            PointF LocationBoundingBox = new PointF(location.X - size.Width / 2, location.Y - size.Height / 2);
            SizeF SizeBoundingBox = new SizeF(size.Height, size.Width);
            BoundingBox = new RectangleF(LocationBoundingBox, SizeBoundingBox);
            State = FigureState.Unselected;
            updateHotSpots();
            this.Path = new GraphicsPath();
            Path.AddEllipse(LocationBoundingBox.X, LocationBoundingBox.Y, SizeBoundingBox.Width, SizeBoundingBox.Height);
            Region = new Region(Path);
            State = FigureState.Unselected;
        }
        public override void updateHotSpots()
        {
            objects.Clear();
            List<PointF> points = new List<PointF>();
            points.Add(new PointF(BoundingBox.Location.X + Size.Width / 2, BoundingBox.Location.Y));
            points.Add(new PointF(BoundingBox.Location.X + Size.Width / 2, BoundingBox.Location.Y + Size.Height));
            points.Add(new PointF(BoundingBox.Location.X, BoundingBox.Location.Y + Size.Height / 2));
            points.Add(new PointF(BoundingBox.Location.X + Size.Width, BoundingBox.Location.Y + Size.Height / 2));
            for (int i = 0; i < points.Count; i++)
            {
                objects.Add(new HotSpot(points[i]));
            }
        }
        public override void Draw(Graphics graphics, Pen pen, Brush brush, PointF offset)
        {
           
            switch (this.State)
            {
                case FigureState.Editing:
                    Color aux = (brush as SolidBrush).Color;
                    (brush as SolidBrush).Color = Variables.ShapeColor;
                    foreach (HotSpot hotspot in objects)
                    {
                        graphics.FillEllipse(brush, hotspot.Location.X - Variables.HotspotResize.Width / 2, hotspot.Location.Y - Variables.HotspotResize.Height / 2, Variables.HotspotResize.Width, Variables.HotspotResize.Height);
                    }
                    (brush as SolidBrush).Color = aux;
                    break;
            }
        }
    }




}


